package gretha.modelsDeJTable;

import gretha.donnees.Modification;

import javax.swing.table.AbstractTableModel;

public class ModificationTableModel extends AbstractTableModel{


	private static final long serialVersionUID = 3413107220819276947L;
	
	private Modification[] _data;
	private String[] _colName = {"Année","Volume Unitaire","Mortalité"};

	public ModificationTableModel(Modification[] data) {
		super();
		_data = data;
	} 

	public int getColumnCount() {
		return _colName.length;
	}

	public String getColumnName(int columnIndex) {
		return _colName[columnIndex];
	}

	public int getRowCount() {
		return _data == null ? 0 : _data.length;
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		
		switch ( columnIndex ) {
		case 0 : return new Integer(_data[rowIndex].getAnnee());
		case 1 : return new Double(_data[rowIndex].getVolumeUnitaire());
		case 2 : return new Double(_data[rowIndex].getTauxDeMortalite());
		}
		return "";
	}

	public boolean isCellEditable(int rowIndex, int columnIndex) {
		return false;
	}

	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
	}

	public Class<? extends Object> getColumnClass(int columnIndex) {
		switch(columnIndex){
		case 0:
			return Integer.class;
		case 1:
			return Double.class;
		case 2:
			return Double.class;
		default:
			return Object.class;
		}
	}

}
